package com.qf.administration.controller;

import com.github.pagehelper.PageInfo;
import com.qf.administration.qo.DriverManageQO;
import com.qf.administration.service.DriverManageService;
import com.qf.administration.vo.DriverManageVO;
import com.qf.common.base.result.RespResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Title: DriverManageController
 * @Description:
 * @author:ZWX
 * @date: 2023/5/24 16:44
 */
@Api(tags = "司机管理")
@RestController
@RequestMapping("/drivermanage")
public class DriverManageController {
    @Resource
    private DriverManageService driverManageService;

    @ApiOperation("添加司机信息")
    @PostMapping("/add")
    @ApiResponses({@ApiResponse(code = 200, message = "成功")})
    public RespResult<String> addDriver(DriverManageQO driverManageQO) {
        return driverManageService.addDriver(driverManageQO);
    }

    @ApiOperation("删除司机信息并且修改驾驶车辆状态")
    @PutMapping("/delete")
    @ApiResponses({@ApiResponse(code = 200, message = "成功")})
    public RespResult<String> deleteDriver(@RequestParam int id) {
        return driverManageService.deleteOneDriver(id);
    }

    @ApiOperation("修改司机信息")
    @PutMapping("/delete")
    @ApiResponses({@ApiResponse(code = 200, message = "成功")})
    public RespResult<String> updateDriver(@RequestBody DriverManageQO driverManageQO) {
        return driverManageService.updateDriver(driverManageQO);
    }

    @ApiOperation("查询司机信息")
    @GetMapping("/list")
    public RespResult<PageInfo<DriverManageVO>> queryDriver(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int size, @RequestParam(required = false) String workType, @RequestParam(required = false) String username, @RequestParam(required = false) String sex, @RequestParam(required = false) String driverNumber, @RequestParam(required = false) String busNumber) {
        return RespResult.success(driverManageService.queryDriver(page, size, workType, username, sex, driverNumber, busNumber));
    }

    @ApiOperation("查询会议室单条信息")
    @GetMapping("/one")
    public DriverManageVO queryDriverOne(@RequestParam int id) {
        return driverManageService.queryDriverOne(id);
    }

}
